from flask import Flask
from flaskDemo.extensions import init_plugins
from .config.config import Config
from flask_socketio import SocketIO, emit,send

socketio = SocketIO()
def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)
    socketio.init_app(app, cors_allowed_origins='*')

    # 初始化拦截器
    init_plugins(app)

    from .views.system.user import user
    from .views.system.menu import menu
    from .views.system.role import role
    from .views.system.depart import depart
    from .views.system.message import message
    from .views.system.dict import dict
    app.register_blueprint(user, url_prefix="/user")
    app.register_blueprint(menu, url_prefix="/menu")
    app.register_blueprint(role, url_prefix="/role")
    app.register_blueprint(depart, url_prefix="/depart")
    app.register_blueprint(message, url_prefix="/message")
    app.register_blueprint(dict, url_prefix="/dict")
    return app